Answer:

If the user hit Enter before typing any characters, the string variable NAME$ would contain no characters. The screen would look like:

Please type your name and hit Enter
? 
Your name is:

Simplified String Input

Input with string variables can get complicated. To keep things simple:

If these rules are followed, then:

The complete set of rules for string input in QBasic are much more complicated. If you follow the three simple rules you will avoid much of the confusion but still be able to write reasonable programs.

Here is the program again:

' Input with Strings
'
PRINT "Please type your name and hit Enter"
INPUT NAME$
PRINT "Your name is:", NAME$
END

Here is a run of the program:

Please type your name and hit Enter
?          Smoky the Bear
Your name is: Smoky the Bear

The user typed in some spaces before the "S" but they did not go into the string variable. (There are ways to input a string that starts with spaces, but you won't need to do that in this course.)

QUESTION 11:

Say that the user runs the program and enters:

?       Attila    the    Hun

What will the program write?